import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import tailwindcss from '@tailwindcss/vite'
// https://vite.dev/config/
export default defineConfig({
  plugins: [react(), tailwindcss(),],
  server: {
    proxy: {
      "/api": {
        target: "http://113.44.139.133:8000",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
      "/upload":{
        target: "http://localhost:3000/",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/static/, ""),
      },
    },
  },
  resolve: {
    alias: {
      // 关键：映射 three 到 node_modules 实际路径
      'three': path.resolve(__dirname, 'node_modules/three'),
      // 额外映射 addons（如果你的项目里有单独的 addons 依赖）
      'three/addons': path.resolve(__dirname, 'node_modules/three/examples/jsm'), 
    }
  }
});
